{{csrf_field()}}
<div class="form-group row">
    <label for="parent_id" class="col-sm-2 col-form-label">父级权限</label>
    <div class="col-sm-5">
        <select name="parent_id" id="parent_id" class="form-control">
            <option value="0">顶级权限</option>
            @forelse($permissions as $p1)
                <option value="{{$p1->id}}" {{ isset($permission->id) && $p1->id == $permission->parent_id ? 'selected' : '' }} >{{$p1->display_name}}</option>
                @if($p1->child->isNotEmpty())
                    @foreach($p1->child as $p2)
                        <option value="{{$p2->id}}" {{ isset($permission->id) && $p2->id == $permission->parent_id ? 'selected' : '' }} >&nbsp;&nbsp;&nbsp;┗━━{{$p2->display_name}}</option>
                        @if($p2->child->isNotEmpty())
                            @foreach($p2->child as $p3)
                                <option value="{{$p3->id}}" {{ isset($permission->id) && $p3->id == $permission->parent_id ? 'selected' : '' }} >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;┗━━{{$p3->display_name}}</option>
                            @endforeach
                        @endif
                    @endforeach
                @endif
            @empty
            @endforelse
        </select>
    </div>
</div>

<div class="form-group row">
    <label for="name" class="col-sm-2 col-form-label">权限名称</label>
    <div class="col-sm-5">
        <input type="text" class="form-control" name="name" id="name" placeholder="权限名称(system.index)" value="{{$permission->name ?? old('name')}}">
    </div>
</div>

<div class="form-group row">
    <label for="display_name" class="col-sm-2 col-form-label">显示名称</label>
    <div class="col-sm-5">
        <input type="text" class="form-control" maxlength="16" id="display_name" name="display_name" value="{{ $permission->display_name ?? old('display_name') }}"  placeholder="请输入显示名称"  >
    </div>
</div>

<div class="form-group row">
    <label for="route" class="col-sm-2 col-form-label">路由名称</label>
    <div class="col-sm-5">
        <input type="text" class="form-control" id="route" name="route" value="{{$permission->route??old('route')}}"   placeholder="请输入路由名称" >
    </div>
</div>


<div class="form-group row">
    <label for="password" class="col-sm-2 col-form-label">类型</label>
    <div class="col-sm-5">
        <label class="radio-inline ">
            <input type="radio" style="width: 18px;height: 18px; margin-right: 5px;" class="custom-radio"  name="type" value="1" {{isset($permission->type) && $permission->type == 1 ?'checked':''}}>按钮
        </label>
        <label class="radio-inline ">
            <input type="radio"  style="width: 18px;height: 18px; margin-right: 5px;"  class="custom-radio"  name="type"  value="2" {{isset($permission->type) && $permission->type == 2 ?'checked':''}}>菜单
        </label>
    </div>
</div>

<div class="form-group row">
    <label for="sort" class="col-sm-2 col-form-label">排序号</label>
    <div class="col-sm-5">
        <input type="number" class="form-control"  id="sort" name="sort"  placeholder="请输入排序号" value="{{$permission->sort??old('sort')}}">
    </div>
</div>

<div class ="col-sm-7" style="text-align: center;">
    <button type="submit" class="btn btn-info">提 交</button>
    <a class="btn btn-default" href="{{route('admin.permission')}}">返 回</a>
</div>